package com.yugu.park.security.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.github.pagehelper.PageInfo;
import com.yugu.park.security.entity.TSysOperLog;
import com.yugu.park.security.mapper.TSysOperLogMapper;
import com.yugu.park.security.service.TSysOperLogService;
import com.yugu.util.SearchPage;
import com.yugu.util.StringUtils;
@Service
public class TSysOperLogServiceImpl implements TSysOperLogService {
	@Resource
	private TSysOperLogMapper mapper;
	@Override
	public void addOrUpdate(TSysOperLog t) {
		TSysOperLog old = mapper.getById(t.getId());
		if(old!=null) {
			Integer businessType = t.getBusinessType();
			if(businessType!=null) {
				old.setBusinessType(businessType);
			}
			String errMsg = t.getErrMsg();
			if(StringUtils.isNotEmpty(errMsg)) {
				old.setErrMsg(errMsg);
			}
			String method = t.getMethod();
			if(StringUtils.isNotEmpty(method)) {
				old.setMethod(method);
			}
			String operIp = t.getOperIp();
			if(StringUtils.isNotEmpty(operIp)) {
				old.setOperIp(operIp);
			}
			String operLocation = t.getOperLocation();
			if(StringUtils.isNotEmpty(operLocation)) {
				old.setOperLocation(operLocation);
			}
			String operName = t.getOperName();
			if(StringUtils.isNotEmpty(operName)) {
				old.setOperName(operName);
			}
			String operParam = t.getOperParam();
			if(StringUtils.isNotEmpty(operParam)) {
				old.setOperParam(operParam);
			}
			String operResult = t.getOperResult();
			if(StringUtils.isNotEmpty(operResult)) {
				old.setOperResult(operResult);
			}
			Integer operType = t.getOperType();
			if(operType!=null) {
				old.setOperType(operType);
			}
			String operUrl = t.getOperUrl();
			if(StringUtils.isNotEmpty(operUrl)) {
				old.setOperUrl(operUrl);
			}
			String requestMethod = t.getRequestMethod();
			if(StringUtils.isNotEmpty(requestMethod)) {
				old.setRequestMethod(requestMethod);
			}
			String title = t.getTitle();
			if(StringUtils.isNotEmpty(title)) {
				old.setTitle(title);
			}
			mapper.modify(old);
		}else {
			//新增
			mapper.insert(t);
		}
		
	}

	@Override
	public void deleteById(String id) {

	}

	@Override
	public TSysOperLog getById(String id) {
		return null;
	}

	@Override
	public PageInfo<TSysOperLog> page(SearchPage<TSysOperLog> search) {
		return null;
	}

}
